<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>

    <script src="${pageContext.request.contextPath}/static/js/jquery.js"></script>
    <script>
        function login() {
            $.ajax({
                url: "${pageContext.request.contextPath}/login",
                method: "post",
                data: {
                    userName: $("#userName").val(),
                    password: $("#password").val()
                },
                success: (res, status) => {
                    console.log(res, status);
                },
                error:(err)=>{
                    console.error(err);
                }
            })
        }

        function getUserList(){
            $.get({
                url:"${pageContext.request.contextPath}/ajax2",
                success:(res)=>{
                    console.log(res);
                },
                error:(err)=>{
                    console.error(err);
                }
            })
        }
    </script>

</head>
<body>

<input type="text" id="userName"/>
<input type="password" id="password"/>
<button id="login" onclick="login()">提交</button>
<button id="getUserList" onclick="getUserList()">获取用户列表</button>
</body>
</html>
